//
//  ZTimeOutOrderAlertDealView.m
//  DistributorAB
//
//  Created by LZY on 2019/10/17.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "ZTimeOutOrderAlertDealView.h"

@implementation ZTimeOutOrderAlertDealView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupViewAction];
    }
    return self;
}
#pragma mark - 界面布局方法
- (void)setupViewAction{
    
    self.backgroundColor = kColorWithHex(0xb1b0af);
    
    UIView *viewCenter = [UIView new];
    viewCenter.backgroundColor = kColorWithHex(0xffffff);
    viewCenter.layer.cornerRadius = 6.0;
    viewCenter.layer.masksToBounds = YES;
    [self addSubview:viewCenter];
    [viewCenter mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(331, 239));
    }];
    
    UIImageView *ivSuccess = [UIImageView new];
    ivSuccess.image = [UIImage imageNamed:@"user_alert_icon"];
    [viewCenter addSubview:ivSuccess];
    
    UILabel *lblNotice = [UILabel new];
    lblNotice.text = @"请及时给用户回复处理结果！";
    lblNotice.textColor = kColorWithHex(0x333333);
    lblNotice.font = [UIFont systemFontOfSize:16];
    lblNotice.textAlignment = NSTextAlignmentCenter;
    [viewCenter addSubview:lblNotice];
    
    UIButton *btnOK = [UIButton buttonWithType:UIButtonTypeCustom];
    [viewCenter addSubview:btnOK];
    [btnOK setTitle:@"完成" forState:UIControlStateNormal];
    [btnOK setTitleColor:kColorWithHex(0xffffff) forState:UIControlStateNormal];
    btnOK.titleLabel.font = [UIFont systemFontOfSize:16];
    [btnOK setBackgroundColor:kColorWithHex(0x70be68)];
    btnOK.layer.cornerRadius = 4.0;
    btnOK.layer.masksToBounds = YES;
    [btnOK addTarget:self action:@selector(btnOKClickAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [ivSuccess mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(viewCenter.mas_centerX);
        make.top.equalTo(viewCenter.mas_top).offset(36);
        make.size.mas_equalTo(CGSizeMake(91, 65));
    }];
    
    [lblNotice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(viewCenter.mas_centerX);
        make.top.equalTo(ivSuccess.mas_bottom).offset(13);
    }];
    
    [btnOK mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(viewCenter.mas_centerX);
        make.top.equalTo(lblNotice.mas_bottom).offset(22);
        make.size.mas_equalTo(CGSizeMake(276, 48));
    }];
}

#pragma mark - 交互方法
//显示
- (void)showView{
    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    self.frame = window.bounds;
    [window addSubview:self];
}
//关闭
- (void)dismissView{
    [self removeFromSuperview];
    if (self.delegate && [self.delegate respondsToSelector:@selector(viewBtnOKClickAction)]) {
        [self.delegate viewBtnOKClickAction];
    }
}
- (void)btnOKClickAction:(UIButton *)sender{
    [self dismissView];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
